package cn.torna.tornaexample.controller.p202111;

import cn.hutool.json.JSONObject;
import cn.torna.tornaexample.common.MyPage;
import cn.torna.tornaexample.common.Result;
import cn.torna.tornaexample.controller.order.vo.OrderDetail;
import cn.torna.tornaexample.controller.product.vo.ProductVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Data;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Tag(name = "测试用例202111", description = "测试用例2022")
@RestController
public class Example20211110Controller {

    @Operation(summary = "参数内容很长")
    @GetMapping("longParam")
    public Result<List<OrderDetail>> longParam(
            @Schema(description = "参数内容很长，<br>换行，参数内容很长参数内容很长参数内容很长参数内容很长参数内容很长" +
                    "参数内容很长参数内容很长参数内容很长参数内容很长参数内容很长参数内容很长" +
                    "参数内容很长参数内容很长参数内容很长参数内容很长参数内容很长参数内容很长" +
                    "参数内容很长参数内容很长参数内容很长参数内容很长参数内容很长参数内容很长")
            String content) {
        List<OrderDetail> list = new ArrayList<>();
        for (int i = 0; i < 100; i++) {
            list.add(OrderDetail.builder()
                            .userId((long) i)
                            .orderNo("order-" + i)
                            .remark("备注")
                            .payTime(new Date())
                            .thisFieldLengthIsVeryLong("content...")
                    .build());
        }
        return Result.ok(list);
    }

    @Operation(summary = "继承第三方类")
    @PostMapping("extendThirdClass")
    public Result<OrderDetail> extendThirdClass(@RequestBody MyPage<ProductVO> paramVo) {
        return Result.ok(new OrderDetail());
    }



    @Operation(summary = "普通字符串")
    @GetMapping("string")
    public String hello() {
        return "hello";
    }

    @Operation(summary = "示例hutool JSONObject", description = "", method = "GET")
    @RequestMapping("/hutoolJSONObject")
    public Result<cn.hutool.json.JSONObject> vvv(@RequestParam RawData m) {
        return Result.ok(new cn.hutool.json.JSONObject());
    }

    @Data
    public static class RawData {
        String type;
        String title;
        JSONObject param;
    }
}
